//
//  LKButton.m
//  卢卡的时光网
//
//  Created by 卡神 on 15/7/17.
//  Copyright © 2015年 lok. All rights reserved.
//

#import "LKButton.h"

@implementation LKButton


- (nonnull instancetype)initWithFrame:(CGRect)frame withImageName:(NSString *)name withLabelText:(NSString *)text {
    if (self = [super initWithFrame:frame]) {
        _imageView = [[UIImageView alloc] initWithFrame:CGRectZero];
        _imageView.contentMode = UIViewContentModeScaleAspectFit;
        _imageView.image = [UIImage imageNamed:name];
        [self addSubview:_imageView];
        
        _label = [[UILabel alloc] initWithFrame:CGRectZero];
        _label.textAlignment = NSTextAlignmentCenter;
        _label.font = [UIFont systemFontOfSize:11];
        _label.text = text;
        _label.textColor = [UIColor whiteColor];
        [self addSubview:_label];
    }
    return self;
}

- (void)layoutSubviews {
    _imageView.frame = CGRectMake((self.frame.size.width - 20) / 2, 5, 20, 20);
    _label.frame = CGRectMake(0, CGRectGetMaxY(_imageView.frame), CGRectGetWidth(self.frame), 20);
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
